App.CheckBoxGrid=function(g){
	 var orderTypeD = Ext.data.Record.create([
          {
			name : 'id'
		}, {
			name : 'hid'
		}, {
			name : 'ord'
		}, {
			name : 'materielid'
		}, {
			name : 'spec'
		}, {
			name : 'factcode'
		}, {
			name : 'barcode'
		}, {
			name : 'amount'
		}, {
			name : 'comeamount'
		}, {
			name : 'inprice'
		}, {
			name : 'taxprice'
		}, {
			name : 'type'
		}, {
			name : 'flag'
		}, {
			name : 'modipid'
		}, {
			name : 'modidate'
		}, {
			name : 'remark'
		}, {
			name : 'attrib1'
		}, {
			name : 'attrib2'
		}, {
			name : 'attrib3'
		}, {
			name : 'attrib4'
		}, {
			name : 'attrib5'
		},{ 
		    name:'username'
		}
      ]);

	var sm = new Ext.grid.CheckboxSelectionModel({handleMouseDown: Ext.emptyFn,singleSelect : true});
    var cm = new Ext.grid.ColumnModel([
		sm,{
			header:'物料ID',
			dataIndex:'idt_materiel',
			width:80
		},{
			header: "物料编码",
			dataIndex: 'materielno',
			width:80
        },{
			header:'物料名称',
			dataIndex:'materielname',
			width:180				
		},{
			header:'物料规格',
			dataIndex:'spec',
			width:80				
		}
    ]);
    cm.defaultSortable = true;
    var SaleArea = Ext.data.Record.create([
           {name: 'idt_materiel'},
           {name: 'materielno'},
           {name: 'materielname'},
           {name: 'spec'}, {
			name : 'attrib1'
		}, {
			name : 'attrib2'
		}, {
			name : 'attrib3'
		}, {
			name : 'attrib4'
		}, {
			name : 'attrib5'
		}
      ]);
	var store = new Ext.data.JsonStore({
		url:'../'+WebServiceUrl,
		baseParams:{trancode:'12130'},
		totalProperty:'totalProperty',
		root:'root',
		fields:SaleArea,
		pruneModifiedRecords:true
	});
	var grid = new Ext.grid.GridPanel({
    	id : 'BaseGrid',
        store: store,
        cm: cm,
        resizeable:true,
        height:330,
        width:500,
		sm:sm,
		loadMask: {msg:'正在加载数据，请稍候。。。'},
		stripeRows:true,
		tbar : ['物料名称：', new Ext.app.SearchField({
				store : store,
				width : 200
			})],
	    bbar: new Ext.PagingToolbar({
	        pageSize: 10,
	        store: store,
	        displayInfo: true,
	        displayMsg: '显示第 {0} 条到 {1} 条记录，一共 {2} 条',
	        emptyMsg: "没有记录"
	    })
    });
    grid.on('rowclick', function(grid, t) {
		if (sm.isSelected(t))
			sm.deselectRow(t);
		else
			sm.selectRow(t, true);
	});
	
    store.load({params:{start:0,limit:10}});
    var win = new Ext.Window({
    	id:'SelGrid',
		title : '物料选择',
		width : 510,
		height : 400,
		closable : false,
		collapsible : false,
		modal : true,
		defaults : {
			border : false
		},
		buttonAlign : 'right',
		items :grid,
		buttons :[{
			text:'确定',
			handler : function(){
				var _record = grid.getSelectionModel().getSelected();
				if (!_record) {
					Ext.MessageBox.alert('警告', '请选择一条信息!');
				} else {
						var m = new orderTypeD({
						materielid:_record.get('idt_materiel'),
						materielname:_record.get('materielname'),
						spec:_record.get('spec'), 
						amount:'0',
						type:'0',
						comeamount:'0',
						inprice:'0',
						taxprice:'0',
						factcode:'',
						barcode:'',
						remark:'备注',
						attrib1:0,
						attrib1_unit:'mm',
						attrib2:0,
						attrib2_unit:'mm',
						attrib3:0,
						attrib3_unit:'mm',
						attrib4:0,
						attrib4_unit:'mm',
						attrib5:0,
						attrib5_unit:'mm',
						username: ''
					});
					var BaseGrid = g;
					var BaseStore = BaseGrid.getStore();
					BaseGrid.stopEditing();
					BaseStore.insert(0,m);
					BaseGrid.startEditing(0, 3);
					BaseStore.getAt(0).dirty=true;	
					BaseStore.commitChanges();
					win.close();
				}
			}
		},{
			text:'关闭',
			handler : function(){
				Ext.getCmp('SelGrid').close();
			}
		}]
    })    
    win.show();
}